package testReg;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Test;

public class TestReg {

	@Test
	public void testReg() {

		Pattern p = Pattern.compile("\\w{3,}");
		String zipCode = "www";
		Matcher m = p.matcher(zipCode);
		System.out.println(m.matches());
	}

	@Test
	public void testReg2() {
		Pattern numberPattern = Pattern.compile("[0-9]{1,3}");
		Matcher numbericMatcher = numberPattern.matcher("12e");
		System.out.println(numbericMatcher.matches());
	}

	@Test
	public void testStringContains() {
		String str = "abc;role:man";
		System.out.println(str.contains("role:man"));
	}

	@Test
	public void testOr() {
		System.out.println(true || false);
		if (true) {
			System.out.println(true);
		} else if (false) {
			System.out.println(false);
		}
	}

	@Test
	public void testW() {
		Pattern p = Pattern.compile("\\w{3,}");
		String zipCode = "HY V";
		Matcher m = p.matcher(zipCode);
		System.out.println(m.matches());
		String s = "A A ";
		System.out.println(s.length());
		String s2 = s.replaceAll(" ", "");
		System.out.println(s2.length());

	}

	@Test
	public void testpOINT() {
		Pattern p = Pattern.compile("(\\s*)|(\\s*[^\\s].{1,}[^\\s].*)");
		String zipCode = "S/S";
		Matcher m = p.matcher(zipCode);
		System.out.println(m.matches());

	}

	@Test
	public void testp2() {
		Pattern p = Pattern.compile("^[A-Za-z]{2}");
		String zipCode = "";
		String z = zipCode.trim();
		Matcher m = p.matcher(z);
		System.out.println(m.matches());
	}

}
